new Vue({
    el: '#app',
    data() {
        return {
            userInfo: {},
            orderList: [{ // 功能入口数据
                name: '全部订单',
                icon: 'admin/icon/merchant.png',
                path: 'pages/my/my-order',
                status: ''
            },{
                name: '待付款',
                icon: 'admin/icon/supply.png',
                path: 'pages/my/my-order',
                status: '0'
            }, {
                name: '待发货',
                icon: 'admin/icon/industry_services.png',
                path: 'pages/my/my-order',
                status: '2'
            }, {
                name: '待收货',
                icon: 'admin/icon/enterprise.png',
                path: 'pages/my/my-order',
                status: '3'
            }, {
                name: '已完成',
                icon: 'admin/icon/purchase.png',
                path: 'pages/my/my-order',
                status: '4'
            }],
            featuresList: [{ // 功能入口数据
                name: '个人信息',
                icon: 'el-icon-user',
                path: ''
            }, {
                name: '地址管理',
                icon: 'el-icon-place',
                path: 'pages/my/my-address'
            }, {
                name: '售后订单',
                icon: 'el-icon-document',
                path: ''
            }, {
                name: '我的采购',
                icon: 'el-icon-s-order',
                path: 'pages/my/my-purchase'
            }, {
                name: '销售订单',
                icon: 'el-icon-s-order',
                path: 'pages/my/my-sales-order'
            }, {
                name: '我的报价',
                icon: 'el-icon-s-goods',
                path: 'pages/my/my-sales'
            }, {
                name: '采购订单',
                icon: 'el-icon-s-goods',
                path: 'pages/my/my-purchase-order'
            }, {
                name: '我的收藏',
                icon: 'el-icon-star-off',
                path: ''
            }, {
                name: '我的浏览',
                icon: 'el-icon-mobile-phone',
                path: ''
            }, {
                name: '平台客服',
                icon: 'el-icon-service',
                path: ''
            }]
        }
    },
    beforeCreate() {
        function setRem() {
            const designWidth = 750; // 设计稿宽度（rpx）
            const maxWidth = 540; // 可选：限制最大宽度（如手机端常见值）
            const screenWidth = Math.min(window.innerWidth, maxWidth);
            const scale = screenWidth / designWidth;
            document.documentElement.style.fontSize = scale + 'px';
        }
        setRem();//1rem = 0.5px 对标小程序在 375px 宽的屏幕上，1rpx = 0.5px（因为 750rpx / 375px = 2）
    },
    mounted() {
        this.init();
    },
    computed: {

    },
    methods: {
        async init() {
            try {
                const data = await generalApi.generalQueryBySQLSerialNumberWithClient({
                    SQLSerialNumber: 's_user_and_enterprise',
                    Condition: utf8ToBase64(`${getCookie('user') || '-'},${getCookie('enterprise') || '-'}`),
                });
                if (data.length == 1) {
                    this.userInfo = data[0];   
                }
            } catch (error) {
                console.error(error);   
            }
        },
        toPath(url, status) {// 跳转页面
            if(url) {
                const qs = (typeof status !== 'undefined' && status !== null) ? `?status=${encodeURIComponent(status)}` : '';
                window.location.href = `../../${url}.html${qs}`;
            } else {
                this.$showToast({
                    title:'暂未开放'
                });
            }
        },
        handleLogin() {
            // wx.miniProgram.navigateTo({
            //     url: `/pages/index/login`,
            // })
            window.location.href = absolutepath() + 'login.html'
        }

    },
})
